/*
 *  Copyright 2008-2010 www.jrails.org
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.rails.extjs.form;

import java.util.List;

import org.rails.extjs.Option;

public class HtmlEditor extends Field {

	public HtmlEditor() {
		super();
	}

	public HtmlEditor(Option configOptions) {
		super(configOptions);
	}

	public HtmlEditor(String name) {
		super(name);
	}

	public HtmlEditor(String name, String fieldLabel) {
		super(name, fieldLabel);
	}

	public HtmlEditor(String name, String fieldLabel, Object value) {
		super(name, fieldLabel, value);
	}
	
	public void setCreateLinkText(String createLinkText){
		addOption("createLinkText", createLinkText);
	}
	
	public String getCreateLinkText(){
		return getString("createLinkText", "");
	}
	

	public void setDefaultLinkValue(String defaultLinkValue){
		addOption("defaultLinkValue",defaultLinkValue);
	}
	
	public String getDefaultLinkValue(){
		return getString("defaultLinkValue","http://");
	}
	
	public void setDefaultValue(String defaultValue){
		addOption("defaultValue", defaultValue);
	}
	
	public String getDefaultValue(){
		return getString("defaultValue", "");
	}
	
	public void setEnableAlignments(Boolean enableAlignments){
		addOption("enableAlignments", enableAlignments);
	}
	
	public Boolean isEnableAlignments(){
		return getBoolean("enableAlignments", true);
	}
	
	public void setEnableColors(Boolean enableColors){
		addOption("enableColors",enableColors);
	}
	
	public Boolean isEnableColors(){
		return getBoolean("enableColors",true);
	}
	
	public void setEnableFont(Boolean enableFont){
		addOption("enableFont", enableFont);
	}
	
	public Boolean isEnableFont(){
		return getBoolean("enableFont", true);
	}
	
	public void setEnableFontSize(Boolean enableFontSize){
		addOption("enableFontSize", enableFontSize);
	}
	
	public Boolean isEnableFontSize(){
		return getBoolean("enableFontSize",true);
	}
	
	public void setEnableFormat(Boolean enableFormat){
		addOption("enableFormat", enableFormat);
	}
	
	public Boolean isEnableFormat(){
		return getBoolean("enableFormat", true);
	}
	
	public void setEnableLinks(Boolean enableLinks){
		addOption("enableLinks", enableLinks);
	}
	
	public Boolean isEnableLinks(){
		return getBoolean("enableLinks",true);
	}
	
	
	public void setEnableLists(Boolean enableLists){
		addOption("enableLists", enableLists);
	}
	
	public Boolean isEnableLists(){
		return getBoolean("enableLists", true);
	}
	
	public void setEnableSourceEdit(Boolean enableSourceEdit){
		addOption("enableSourceEdit", enableSourceEdit);
	}
	
	public Boolean isEnableSourceEdit(){
		return getBoolean("enableSourceEdit", true);
	}
	
	public void setFontFamilies(List<String> fontFamilies){
		addOption("fontFamilies", fontFamilies);
	}
	
	@SuppressWarnings("unchecked")
	public List<String> getFontFamilies(){
		return (List<String>)getOption("fontFamilies");
	}
	
	@Override
	public String getScript() {
		script = new StringBuffer("");
		createItems();
		script.append("new Ext.form.HtmlEditor(");
		script.append(createOptions());
		script.append(")");
		return script.toString();
	}
}
